package com.atguigu.juc.juc20210301;

@FunctionalInterface
interface Foo
{
    //public void sayHello();
    public int add(int x,int y);

    default int sub(int x,int y)
    {
        return x - y;
    }

    public static int div(int x,int y)
    {
        return x/y;
    }
}


/**
 * @auther zzyy
 * @create 2020-03-26 11:40
 *lambda Express
 * 前提：函数式接口(接口里面有且仅有一个方法) ---> lambda Express
 *
 * 1 拷贝小括号，写死右箭头，落地大括号
 * 2 @FunctionalInterface
 * 3 default方法内方法实现增强
 * 4 静态方法实现增强
 *
 */
public class LambdaExpressDemo
{
    public static void main(String[] args)
    {
        /*Foo foo = new Foo()
        {
            @Override
            public void sayHello()
            {
                System.out.println("-----hello 0301wh");
            }
        };
        foo.sayHello();*/

        /*Foo foo = () -> {System.out.println("----hello 0301wh lambda express");};
        foo.sayHello();*/

        Foo foo = (x,y) -> {
            System.out.println("----come in");
            return x + y;
        };
        System.out.println(foo.add(3, 2));

        System.out.println(foo.sub(10, 2));

        System.out.println(Foo.div(10, 5));
    }
}
